<template>
  <contents :heightInclude="['navBar']" class="balance_page">
    <view class="balance-info">
      <view class="balance">
        <view>可提现余额（元）</view>
        <view style="font-size: 48rpx; margin-top: 10rpx">{{
          balanceInfo.aviAmt || '0.00'
        }}</view>
        <view style="margin-top: 30rpx; line-height: 36rpx" >
          <text>
            {{
              show ? 
              walletInfo.acctNo
              :
              walletInfo.acctNo &&
              walletInfo.acctNo.substr(0, 4) +
                ' * * * * * * * * * * * ' +
                walletInfo.acctNo.substr(walletInfo.acctNo.length - 3)
            }}
          </text>
          <u-icon v-if="show" @click="show = !show" style="margin-left: 20rpx" name="eye-fill" color="#fff" size="36"></u-icon>
          <u-icon v-else @click="show = !show" style="margin-left: 20rpx" name="eye-off" color="#fff" size="36"></u-icon>
        </view>
        <view class="withdrawal" @click="navSwitch('/pages/wallet/withdrawal')">
          <image class="wallet-icon" src="@/static/images/wallet-icon.png" />
          <text>提现</text>
          <u-icon name="arrow-right" color="#fff" size="20"></u-icon>
        </view>
      </view>
      <view class="balance-tab">
        <view class="item" style="border-right: 1px solid #eaeaea">
          <view>￥{{ balanceInfo.aviAmt || '0.00' }}</view>
          <view style="color: #bbbbbb; font-size: 24rpx">账户余额（元）</view>
        </view>
        <view class="item" style="padding-left: 66rpx">
          <view>￥{{ balanceInfo.storeToBeSettledMoney || '0.00' }}</view>
          <view style="color: #bbbbbb; font-size: 24rpx">待结算余额（元）</view>
        </view>
      </view>
    </view>
    <view class="cell">
      <view class="cell-item" @click="navSwitch('/pages/wallet/detailedList')">
        <view class="left">
          <image class="cell-icon" src="@/static/images/minxi.png" />
          <view>收支明细</view>
        </view>
        <u-icon name="arrow-right" color="#999999" size="20"></u-icon>
      </view>
      <view
        class="cell-item"
        style="margin-top: 1rpx"
        @click="navSwitch('/pages/wallet/carDetail')"
      >
        <view class="left">
          <image class="cell-icon" src="@/static/images/car.png" />
          <view>查看银行卡</view>
        </view>
        <u-icon name="arrow-right" color="#999999" size="20"></u-icon>
      </view>
    </view>
  </contents>
</template>
<script>
import { getMyWalletInfo, doVisAcctBalance } from '@/api/http/wallet'
export default {
  data() {
    return {
      walletInfo: {},
      balanceInfo: {},
      show: false
    }
  },

  onLoad() {
    this.getData()
  },

  methods: {
    getData() {
      getMyWalletInfo().then((res) => {
        if (res.code === 200 && res.data) {
          this.walletInfo = res.data
        }
      })
      doVisAcctBalance().then((res) => {
        if (res.code === 200 && res.data) {
          this.balanceInfo = res.data
        }
      })
    },

    navSwitch(url) {
      uni.navigateTo({
        url
      })
    }
  }
}
</script>
<style lang="scss">
.balance_page {
  .balance-info {
    background-color: #fff;
    overflow: hidden;
    border-top: 1px solid #f2f2f2;
    .balance {
      width: 690rpx;
      min-height: 254rpx;
      background: url('~@/static/images/balance.png') no-repeat;
      background-size: 100% 100%;
      margin: 16rpx auto 31rpx auto;
      color: #fff;
      font-size: 28rpx;
      padding-left: 25rpx;
      padding-top: 40rpx;
      box-sizing: border-box;
      position: relative;
      .withdrawal {
        position: absolute;
        right: 0;
        top: 110rpx;
        width: 152rpx;
        height: 46rpx;
        background: linear-gradient(
          270deg,
          #686fbb 0%,
          #7d83c5 100%,
          #7a9edb 100%
        );
        border-radius: 23rpx 0px 0px 23rpx;
        display: flex;
        font-size: 24rpx;
        padding-left: 15rpx;
        justify-content: space-around;
        align-items: center;
        .wallet-icon {
          width: 23rpx;
          height: 23rpx;
        }
      }
    }
    .balance-tab {
      height: 80rpx;
      display: flex;
      margin-bottom: 32rpx;
      .item {
        color: #222;
        font-size: 30rpx;
        width: 50%;
        padding-left: 127rpx;
        box-sizing: border-box;
      }
    }
  }

  .cell {
    margin-top: 20rpx;
    .cell-item {
      background-color: #fff;
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 98rpx;
      padding: 0 37rpx;
      .left {
        display: flex;
        align-items: center;
      }
      .cell-icon {
        width: 44rpx;
        height: 44rpx;
        margin-right: 24rpx;
      }
    }
  }
}
</style>